package com.baoyi.pooke;

import net.youmi.android.AdManager;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;

import com.baoyi.adapter.ButtonsAdapter;
import com.baoyi.adapter.PaiKuUIAdapter;
import com.baoyi.content.content;
import com.baoyi.widget.PaiKuItemWidget;

public class PaiKuUI extends Activity {
	private PaiKuUIAdapter adapter;
	static {
		AdManager.init(content.id, content.pwd, content.time, content.con,
				content.banben);
	}

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.paikulist);
		gridView = (GridView) findViewById(R.id.gridview);
		gridView.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				PaiKuItemWidget imageView = (PaiKuItemWidget) arg1;
				Intent item = new Intent(PaiKuUI.this, ImageViewUI.class);
				item.putExtra("id", imageView.getImageItem().getId());
				startActivity(item);
			}
		});
		adapter = new PaiKuUIAdapter(this);
		gridView.setAdapter(adapter);
		gridViewbuttons = (GridView) findViewById(R.id.gridbuttons);
		ButtonsAdapter buttonsAdapter = new ButtonsAdapter(this);
		gridViewbuttons.setAdapter(buttonsAdapter);
	}

	private GridView gridViewbuttons;

	private GridView gridView;
}
